#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll t; cin >> t;
	while (t--) {
		ll n, k; cin >> n >> k;
		string s; cin >> s;
		ll x = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'B') x++;
		}
		if (x == k) {
			cout << 0 << endl;
			continue;
		}
		else if (x < k) {
			cout << 1 << endl;
			ll cnt = 0;
			for (int i = 0; i < n; i++) {
				if (s[i] == 'A') cnt++;
				if (cnt == k - x) {
					cout << i + 1 << " " << 'B' << endl;
					break;
				}
			}
		}
		else if (x > k) {
			cout << 1 << endl;
			ll cnt = 0;
			for (int i = 0; i < n; i++) {
				if (s[i] == 'B') cnt++;
				if (cnt == x - k) {
					cout << i + 1 << " " << 'A' << endl;
					break;
				}
			}
		}
	}
	return 0;
}